<extend name="Layout/ins_page" />
<block name="content">
    <link href="/sap/demo.css" rel="stylesheet" type="text/css" />
    <script src="/sap/scripts/boot.js" type="text/javascript"></script>



    <legend><span></span></legend>
    <div  id='fm1'>
        <div class="fieldset-body">

            <div id="tabs1" class="mini-tabs" activeIndex="0" style="width:100%;margin-top: 5px;overflow:auto;" plain="false"
                 buttons="#tabsButtons"
            >
                <div title="列表：" >

                    <div id="datagrid1" class="mini-datagrid" style="height:430px;width: 100%;"
                         url="/SapSupplier/getlistupdatesapitemfromexcel" idField="id"
                         allowResize="true"
                         allowCellEdit="true" allowCellSelect="true" multiSelect="true"
                         allowCellValid="true" oncellvalidation=""
                    >

                        <div property="columns">

                            <div field="list_tag"  headerAlign="center"  >清单
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>

                            <div field="ctime"  headerAlign="center"  >上传时间
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>
                            <div field="upload_emp_no"  headerAlign="center"  >上传人
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>
                            <div field="status"  headerAlign="center"  >状态
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>
                            <div field="operate"  headerAlign="center"  >操作
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>

                        </div>
                    </div>
                </div>
                <!-- <div title="Tab2" iconCls="" >
                    2
                </div> -->
            </div>
        </div>
    </div>


    </body>
    <script type="text/javascript">
        mini.parse();
        var grid = mini.get("datagrid1");
        grid.setPageSize(50);
        grid.load();
        grid.on("drawcell", function (e) {
            var record = e.record,
                column = e.column,
                field = e.field,
                value = e.value;

            //格式化日期
            if (field == "ctime") {
                if (mini.isDate(value)) e.cellHtml = mini.formatDate(value, "yyyy-MM-dd HH:mm:ss");

            }

            if (field == "list_tag") {
                e.cellHtml = '<a href="javascript:showList('+value+')"  >' +value+ '</a>';
            }

            if (field == "operate") {
                e.cellHtml = '<a href="javascript:approve('+record.list_tag+',1)"  >通过</a> - <a href="javascript:approve('+record.list_tag+',0)"  >拒绝</a>';
            }

        });

        function showList(list_tag) {
            mini.open({
                url:  "/index.php?m=&c=SapSupplier&a=showupdatesapitemlist&list_tag="+list_tag,
                title: "清单细节",
                width: 800,
                height: 380,
                ondestroy: function (action) {
                    if (action == "ok") {

                    }

                }
            });

        }


        function approve(list_tag,approve) {

            //确认提示
            mini.confirm("确定？", "确定？",
                function (action) {
                    if (action == "ok") {

                        $.ajax({
                            url: "/SapSupplier/doupdatesapitemfromexcel",
                            type: "post",
                            data: {list_tag: list_tag, approve: approve},
                            dataType: 'json',
                            success: function (data) {
                                mini.alert(data.msg);
                            }
                        });


                    } else {

                    }
                }
            );

        }






    </script>
</block>

